//package com.jackrain.clouddata.sys.config;/**
// * Created by Administrator on 2017/4/14.
// */
//
//import com.aliyun.openservices.ons.api.MessageListener;
//import com.aliyun.openservices.ons.api.bean.ConsumerBean;
//import com.aliyun.openservices.ons.api.bean.ProducerBean;
//import com.aliyun.openservices.ons.api.bean.Subscription;
//import com.jackrain.clouddata.oms.mq.MQMessageListener;
//import com.jackrain.nea.config.PropertiesConf;
//import com.jackrain.nea.util.ApplicationContextHandle;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.CommandLineRunner;
//import org.springframework.core.annotation.Order;
//import org.springframework.stereotype.Component;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * Description: 启动完成之后自动消费多个 topic
// * Created with IntelliJ IDEA.
// * User: cs
// * Date: 2017/4/14
// * Time: 10:00
// */
//@Component
//@Slf4j
//@Order(99)
//public class ConsumerClientConfig implements CommandLineRunner {
//
//    @Autowired
//    private PropertiesConf pconf;
//
//    private Map<Subscription, MessageListener> map = new HashMap<Subscription, MessageListener>();
//
//
//
//    @Override
//    public void run(String... args) throws Exception {
//        initSubscription();
//        ProducerBean producerBean = (ProducerBean) ApplicationContextHandle.getBean(ProducerBean.class);
//        //producerBean.start();
//        ConsumerBean consumerBean = (ConsumerBean) ApplicationContextHandle.getBean(ConsumerBean.class);
//        consumerBean.setSubscriptionTable(map);
//        consumerBean.start();
//    }
//
//    /**
//     * 初始化订阅关系
//     */
//    private void initSubscription() {
//
//        String tag = pconf.getProperty("ons.tag");
//        Subscription subscription = new Subscription();
//        //订单状态 topic
//        subscription = new Subscription();
//        subscription.setTopic(pconf.getProperty("ons.mq.topic1"));
//        subscription.setExpression(tag);
//        map.put(subscription, new MQMessageListener());
//    }
//
//}
//
